package com.teamcenter.rac.massupdate.databinding;

import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.massupdate.model.UpdateJobModel;
import com.teamcenter.rac.massupdate.utils.MassUpdateHelper;
import com.teamcenter.rac.massupdate.utils.SourceHelper;
import com.teamcenter.rac.util.AdapterUtil;
import org.eclipse.ui.views.properties.IPropertySource;

public class ReplacementPartChangeObservable extends AbstractModelObservable {
	public void doSetValue(Object paramObject) {
		super.doSetValue(paramObject);
		final Object localObject = paramObject;
		AbstractAIFOperation local1 = new AbstractAIFOperation() {
			public void executeOperation() throws Exception {
				UpdateJobModel localUpdateJobModel = ReplacementPartChangeObservable.this.getUpdateJobModel();
				boolean bool = false;
				IPropertySource localIPropertySource1 = (IPropertySource) localObject;
				if (localIPropertySource1 != null) {
					TCSession localTCSession = (TCSession) getSession();
					TCComponent localTCComponent1 = SourceHelper.getAssociatedComponent(localIPropertySource1,
							localTCSession);
					if (localTCComponent1 != null) {
						ReplacementPartChangeObservable.this.fireThumbnailImageRequest(localTCComponent1,
								"replacementPart", "replacementPartImageDescriptor");
						TCComponentItemRevision localTCComponentItemRevision1 = (TCComponentItemRevision) AdapterUtil
								.getAdapter(localTCComponent1, TCComponentItemRevision.class);
						if (localTCComponentItemRevision1 != null) {
							IPropertySource localIPropertySource2 = localUpdateJobModel.getChangeObject();
							if (localIPropertySource2 != null) {
								TCComponent localTCComponent2 = SourceHelper
										.getAssociatedComponent(localIPropertySource2, localTCSession);
								if (localTCComponent2 != null) {
									TCComponentItemRevision localTCComponentItemRevision2 = (TCComponentItemRevision) AdapterUtil
											.getAdapter(localTCComponent2, TCComponentItemRevision.class);
									if ((localTCComponentItemRevision2 != null)
											&& (MassUpdateHelper.isChangeItemRevision(localTCComponentItemRevision2))) {
										bool = MassUpdateHelper.isSolutionFolderAccessible(
												localTCComponentItemRevision2, localTCComponentItemRevision1);
									}
								}
							}
						}
					} else {
						localUpdateJobModel.setReplacementPartImageDescriptor(null);
					}
				} else {
					localUpdateJobModel.setReplacementPartImageDescriptor(null);
				}
				localUpdateJobModel.setSolutionFolderAccessible(bool);
				if ((!bool) && (localUpdateJobModel.isSaveReplacementPartInFolder())) {
					localUpdateJobModel.setSaveReplacementPartInFolder(false);
				}
			}
		};
		getTCSession().queueOperation(local1);
	}
}